﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using DevExpress.XtraEditors.ScrollHelpers;
using LibBot;

namespace NewerthBot
{
    public partial class About : Form
    {
        ScrollBarAPIHelper scroll;

        [DllImport("User32.dll", EntryPoint = "GetScrollPos")]
        static extern int GetScrollPos(IntPtr hWnd, int nBar);

        const int SB_VERT = 1;

        public About()
        {
            InitializeComponent();

            scroll = new ScrollBarAPIHelper();
            scroll.Init(txtLicense, this);
            scroll.UpdateScrollBars();
        }

        private void About_Load(object sender, EventArgs e)
        {
            this.Location = new Point(this.Location.X - 12, this.Location.Y + 7);

            foreach (IPlugin plugin in Program.Core.Plugins)
            {
                ListViewItem lvi = new ListViewItem(plugin.Name);
                lvi.SubItems.Add(plugin.Version);
                lvi.SubItems.Add(plugin.Description);

                lstPlugins.Items.Add(lvi);
            }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void txtLicense_VScroll(object sender, EventArgs e)
        {
            scroll.VScroll.Value = GetScrollPos(txtLicense.Handle, SB_VERT);
        }
    }
}
